<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-row class="cu-common-search-box" :gutter="20">
        <el-form @submit.native.prevent style="display: flex;flex-wrap: wrap">
          <el-col :span="6">
            <el-form-item label="校区品牌">
              <el-select v-model="query.brand" placeholder="请选择校区品牌" filterable clearable>
                <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in brandOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="督导校区">
              <el-select v-model="query.campusId" placeholder="督导校区" @focus="loadCampusOptions" filterable clearable>
                <el-option v-for="(item, index) in campusOptions" :key="index" :label="item.fullName" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="督导师">
              <userSelect v-model="query.counselor" placeholder="请选择督导师" />
            </el-form-item>
          </el-col>
          <template v-if="showAll">
            <el-col :span="6">
              <el-form-item label="校区区域">
                <custom-address v-model="query.area" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="督导开始日期">
                <el-date-picker v-model="query.startDate" type="daterange" value-format="yyyy-MM-dd" format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="督导类型">
                <el-select v-model="query.type" placeholder="督导类型" clearable>
                  <el-option v-for="(item, index) in typeOptions" :key="index" :label="item.fullName" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>
          </template>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
              <el-button type="text" icon="el-icon-arrow-down" @click="showAll = true" v-if="!showAll">展开</el-button>
              <el-button type="text" icon="el-icon-arrow-up" @click="showAll = false" v-else>收起</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div>
            <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()" v-has="'btn_add'">新增</el-button>
            <el-button type="text" icon="el-icon-download" @click="exportData()" v-has="'btn_download'">导出</el-button>
            <el-button type="text" icon="el-icon-delete" @click="handleBatchRemoveDel()" v-has="'btn_batchRemove'">批量删除</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" :data="list" has-c @selection-change="handleSelectionChange">
          <el-table-column label="品牌" prop="brand" align="center" width="80">
            <template slot-scope="scope">
              {{ scope.row.brand | dynamicCodeText(brandOptions) }}
            </template>
          </el-table-column>
          <el-table-column label="督导校区" prop="campusName" align="left" v-if="custom.hasP('campusName')" min-width="260" show-overflow-tooltip />
          <el-table-column prop="counselorName" label="督导师" align="left" v-if="custom.hasP('counselor')" min-width="80" />
          <el-table-column prop="startDate" label="开始时间" align="center" v-if="custom.hasP('startDate')" :formatter="custom.tableDateFormat" min-width="100" />
          <el-table-column prop="endDate" label="截止时间" align="center" v-if="custom.hasP('endDate')" :formatter="custom.tableDateFormat" min-width="100" />
          <el-table-column prop="type" label="督导类型" align="center" v-if="custom.hasP('type')" min-width="100">
            <template slot-scope="scope">
              {{ scope.row.type | dynamicText(typeOptions) }}
            </template>
          </el-table-column>

          <el-table-column prop="teacherCount" label="老师人数" align="right" v-if="custom.hasP('teacherCount')" min-width="80" />
          <el-table-column prop="studentCount" label="学生人数" align="right" v-if="custom.hasP('studentCount')" min-width="80" />
          <el-table-column prop="sparkleMemo" label="校区亮点说明" align="left" v-if="custom.hasP('sparkleMemo')" min-width="250" show-overflow-tooltip />
          <el-table-column prop="lackMemo" label="校区不足说明" align="left" v-if="custom.hasP('lackMemo')" min-width="250" show-overflow-tooltip />
          <el-table-column prop="score" label="督导评分" align="right" v-if="custom.hasP('score')" min-width="80" />
          <el-table-column prop="createUserName" label="提交人" align="left" v-if="custom.hasP('createUserName')" width="80" />
          <el-table-column prop="createTime" label="提交时间" :formatter="custom.tableDateTimeFormat" align="center" v-if="custom.hasP('createTime')" min-width="120" />
          <el-table-column prop="flowState" label="审批状态" min-width="100" align="center">
            <template slot-scope="scope">
              <el-tag type="primary" v-if="scope.row.flowState == 1">等待审核</el-tag>
              <el-tag type="success" v-else-if="scope.row.flowState == 2">审核通过</el-tag>
              <el-tag type="danger" v-else-if="scope.row.flowState == 3">审核驳回</el-tag>
              <el-tag type="warning" v-else-if="scope.row.flowState == 4">流程撤回</el-tag>
              <el-tag v-else-if="scope.row.flowState == 5" type="info">审核终止</el-tag>
              <el-tag v-else type="info">等待提交</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作" min-width="160" fixed="right" align="center">
            <template slot-scope="scope">
              <el-button type="text" v-has="'btn_edit'" :disabled="[1, 2, 5].indexOf(scope.row.flowState) > -1" @click="addOrUpdateHandle(scope.row.id)">编辑</el-button>
              <el-button type="text" v-has="'btn_remove'" :disabled="[1, 2, 3, 5].indexOf(scope.row.flowState) > -1" @click="handleDel(scope.row.id)" class="cu-table-delBtn">删除</el-button>
              <el-button size="min" type="text" :disabled="!scope.row.flowState" @click="addOrUpdateHandle(scope.row.id, scope.row.flowState)" v-has="'btn_detail'">详情</el-button>
            </template>
          </el-table-column>
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="refresh" />
    <FlowBox v-if="flowVisible" ref="FlowBox" @close="colseFlow" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
